home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / Macintosh Programmer’s Workshop / MPW 3.2 / MPW / Interfaces / PInterfaces / Editions.p < prev    next >
Text File  |  1991-04-17  |  13KB  |  339 lines

  1. {
  2. Created: Tuesday, January 29, 1991 at 6:35 PM
  3.     Editions.p
  4.     Pascal Interface to the Macintosh Libraries
  5.  
  6.         Copyright Apple Computer, Inc.    1989-1990
  7.         All rights reserved
  8. }
  9.  
  10.  
  11. {$IFC UNDEFINED UsingIncludes}
  12. {$SETC UsingIncludes := 0}
  13. {$ENDC}
  14.  
  15. {$IFC NOT UsingIncludes}
  16.     UNIT Editions;
  17.     INTERFACE
  18. {$ENDC}
  19.  
  20. {$IFC UNDEFINED UsingEditions}
  21. {$SETC UsingEditions := 1}
  22.  
  23. {$I+}
  24. {$SETC EditionsIncludes := UsingIncludes}
  25. {$SETC UsingIncludes := 1}
  26. {$IFC UNDEFINED UsingMemory}
  27. {$I $$Shell(PInterfaces)Memory.p}
  28. {$ENDC}
  29. {$IFC UNDEFINED UsingTypes}
  30. {$I $$Shell(PInterfaces)Types.p}
  31. {$ENDC}
  32. {$IFC UNDEFINED UsingFiles}
  33. {$I $$Shell(PInterfaces)Files.p}
  34. {$ENDC}
  35. {$IFC UNDEFINED UsingAliases}
  36. {$I $$Shell(PInterfaces)Aliases.p}
  37. {$ENDC}
  38. {$SETC UsingIncludes := EditionsIncludes}
  39.  
  40. CONST
  41.  
  42. { resource types  }
  43. rSectionType = 'sect';                      { ResType of saved SectionRecords }
  44.  
  45. { section types }
  46. stSubscriber = $01;
  47. stPublisher = $0A;
  48.  
  49. sumAutomatic = 0;                           { subscriber update mode - Automatically     }
  50. sumManual = 1;                              { subscriber update mode - Manually }
  51. pumOnSave = 0;                              { publisher update mode - OnSave            }
  52. pumManual = 1;                              { publisher update mode - Manually }
  53.  
  54. kPartsNotUsed = 0;
  55. kPartNumberUnknown = -1;                    { misc }
  56.  
  57. kPreviewWidth = 120;
  58. kPreviewHeight = 120;
  59.  
  60. kPublisherDocAliasFormat = 'alis';
  61. kPreviewFormat = 'prvw';
  62. kFormatListFormat = 'fmts';
  63.  
  64. { bits for formatsMask }
  65. kPICTformatMask = 1;
  66. kTEXTformatMask = 2;
  67. ksndFormatMask = 4;
  68.  
  69. { Finder types for edition files }
  70. kPICTEditionFileType = 'edtp';
  71. kTEXTEditionFileType = 'edtt';
  72. ksndEditionFileType = 'edts';
  73. kUnknownEditionFileType = 'edtu';
  74.  
  75. { pseudo-item hits for dialogHooks 
  76.  the first if for NewPublisher or NewSubscriber Dialogs }
  77. emHookRedrawPreview = 150;
  78.  
  79. { the following are for SectionOptions Dialog }
  80. emHookCancelSection = 160;
  81. emHookGoToPublisher = 161;
  82. emHookGetEditionNow = 162;
  83. emHookSendEditionNow = 162;
  84. emHookManualUpdateMode = 163;
  85. emHookAutoUpdateMode = 164;
  86.  
  87. { the refcon field of the dialog record during a modalfilter 
  88.  or dialoghook contains one the following }
  89. emOptionsDialogRefCon = 'optn';
  90. emCancelSectionDialogRefCon = 'cncl';
  91. emGoToPubErrDialogRefCon = 'gerr';
  92. kFormatLengthUnknown = -1;
  93.  
  94. TYPE
  95. SectionType = SignedByte;                   { one byte, stSubscriber or stPublisher }
  96. TimeStamp = LONGINT;                        { seconds since 1904 }
  97. FormatType = PACKED ARRAY [1..4] OF CHAR;   { similar to ResType as used by scrap mgr }
  98. EditionRefNum = Handle;                     { used in Edition I/O }
  99. { update modes }
  100. UpdateMode = INTEGER;                       { sumAutomatic, pumSuspend, etc }
  101.  
  102. SectionPtr = ^SectionRecord;
  103. SectionHandle = ^SectionPtr;
  104. SectionRecord = RECORD
  105.     version: SignedByte;                    { always 0x01 in system 7.0 }
  106.     kind: SectionType;                      { stSubscriber or stPublisher }
  107.     mode: UpdateMode;                       { auto or manual }
  108.     mdDate: TimeStamp;                      { last change in document }
  109.     sectionID: LONGINT;                     { app. specific, unique per document }
  110.     refCon: LONGINT;                        { application specific }
  111.     alias: AliasHandle;                     { handle to Alias Record }
  112.     subPart: LONGINT;                       { which part of container file }
  113.     nextSection: SectionHandle;             { for linked list of app's Sections }
  114.     controlBlock: Handle;                   { used internally }
  115.     refNum: EditionRefNum;                  { used internally }
  116.     END;
  117.  
  118. EditionContainerSpecPtr = ^EditionContainerSpec;
  119. EditionContainerSpec = RECORD
  120.     theFile: FSSpec;
  121.     theFileScript: ScriptCode;
  122.     thePart: LONGINT;
  123.     thePartName: Str31;
  124.     thePartScript: ScriptCode;
  125.     END;
  126.  
  127. EditionInfoRecord = RECORD
  128.     crDate: TimeStamp;                      { date EditionContainer was created }
  129.     mdDate: TimeStamp;                      { date of last change }
  130.     fdCreator: OSType;                      { file creator }
  131.     fdType: OSType;                         { file type }
  132.     container: EditionContainerSpec;        { the Edition }
  133.     END;
  134.  
  135. NewPublisherReply = RECORD
  136.     canceled: BOOLEAN;                      { O }
  137.     replacing : BOOLEAN;
  138.     usePart: BOOLEAN;                       { I }
  139.     preview: Handle;                        { I }
  140.     previewFormat: FormatType;              { I }
  141.     container: EditionContainerSpec;        { I/O }
  142.     END;
  143.  
  144. NewSubscriberReply = RECORD
  145.     canceled: BOOLEAN;                      { O }
  146.     formatsMask: SignedByte;
  147.     container: EditionContainerSpec;        {I/O}
  148.     END;
  149.  
  150. SectionOptionsReply = RECORD
  151.     canceled: BOOLEAN;                      { O }
  152.     changed: BOOLEAN;                       { O }
  153.     sectionH: SectionHandle;                { I }
  154.     action: ResType;                        { O }
  155.     END;
  156.  
  157.  
  158. ExpModalFilterProcPtr = ProcPtr;            { FUNCTION Filter(theDialog: DialogPtr; VAR theEvent: EventRecord; itemOffset: INTEGER; VAR itemHit: INTEGER; yourDataPtr: Ptr): BOOLEAN; }
  159. ExpDlgHookProcPtr = ProcPtr;                { FUNCTION Hook(itemOffset, item: INTEGER; theDialog: DialogPtr; yourDataPtr: Ptr): INTEGER; }
  160.  
  161. FormatIOVerb = (ioHasFormat,ioReadFormat,ioNewFormat,ioWriteFormat);
  162.  
  163.  
  164. FormatIOParamBlock = RECORD
  165.     ioRefNum: LONGINT;
  166.     format: FormatType;
  167.     formatIndex: LONGINT;
  168.     offset: LONGINT;
  169.     buffPtr: Ptr;
  170.     buffLen: LONGINT;
  171.     END;
  172.  
  173.  
  174. FormatIOProcPtr = ProcPtr;                  { FUNCTION IO(selector: FormatIOVerb; VAR PB: FormatIOParamBlock): OSErr; }
  175.  
  176. EditionOpenerVerb = (eoOpen,eoClose,eoOpenNew,eoCloseNew,eoCanSubscribe);
  177.  
  178.  
  179. EditionOpenerParamBlock = RECORD
  180.     info: EditionInfoRecord;
  181.     sectionH: SectionHandle;
  182.     document: FSSpecPtr;
  183.     fdCreator: OSType;
  184.     ioRefNum: LONGINT;
  185.     ioProc: FormatIOProcPtr;
  186.     success: BOOLEAN;
  187.     formatsMask: SignedByte;
  188.     END;
  189.  
  190.  
  191. EditionOpenerProcPtr = ProcPtr;             { FUNCTION Opener(selector: EditionOpenerVerb; VAR PB: EditionOpenerParamBlock): OSErr; }
  192.  
  193. CONST
  194.  
  195.     Section events now arrive in the message buffer using the AppleEvent format.
  196.     The direct object parameter is an aeTemporaryIDParamType ('tid '). The temporary
  197.     ID's type is rSectionType ('sect') and the 32-bit value is a SectionHandle.
  198.     The following is a sample buffer
  199.     
  200.     name            offset    contents
  201.     ----            ------    --------
  202.     
  203.     header            0        'aevt'
  204.     majorVersion    4        0x01
  205.     minorVersion    6        0x01
  206.     endOfMetaData    8        ';;;;' 
  207.     directObjKey    12        '----' 
  208.     paramType        16        'tid ' 
  209.     paramLength        20        0x0008 
  210.     tempIDType        24        'sect' 
  211.     tempID             28        the SectionHandle <-- this is want you want}
  212.  
  213. sectionEventMsgClass = 'sect';
  214. sectionReadMsgID = 'read';
  215. sectionWriteMsgID = 'writ';
  216. sectionScrollMsgID = 'scrl';
  217. sectionCancelMsgID = 'cncl';
  218.  
  219. FUNCTION InitEditionPack: OSErr;
  220.     INLINE $3F3C,$0011,$303C,$0100,$A82D;
  221. FUNCTION NewSection(container: EditionContainerSpec;
  222.                     sectionDocument: FSSpecPtr;
  223.                     kind: SectionType;
  224.                     sectionID: LONGINT;
  225.                     initalMode: UpdateMode;
  226.                     VAR sectionH: SectionHandle): OSErr;
  227.     INLINE $303C,$0A02,$A82D;
  228. FUNCTION RegisterSection(sectionDocument: FSSpec;
  229.                          sectionH: SectionHandle;
  230.                          VAR aliasWasUpdated: BOOLEAN): OSErr;
  231.     INLINE $303C,$0604,$A82D;
  232. FUNCTION UnRegisterSection(sectionH: SectionHandle): OSErr;
  233.     INLINE $303C,$0206,$A82D;
  234. FUNCTION IsRegisteredSection(sectionH: SectionHandle): OSErr;
  235.     INLINE $303C,$0208,$A82D;
  236. FUNCTION AssociateSection(sectionH: SectionHandle;
  237.                           newSectionDocument: FSSpecPtr): OSErr;
  238.     INLINE $303C,$040C,$A82D;
  239. FUNCTION CreateEditionContainerFile(editionFile: FSSpec;
  240.                                     fdCreator: OSType;
  241.                                     editionFileNameScript: ScriptCode): OSErr;
  242.     INLINE $303C,$050E,$A82D;
  243. FUNCTION DeleteEditionContainerFile(editionFile: FSSpec): OSErr;
  244.     INLINE $303C,$0210,$A82D;
  245. FUNCTION OpenEdition(subscriberSectionH: SectionHandle;
  246.                      VAR refNum: EditionRefNum): OSErr;
  247.     INLINE $303C,$0412,$A82D;
  248. FUNCTION OpenNewEdition(publisherSectionH: SectionHandle;
  249.                         fdCreator: OSType;
  250.                         publisherSectionDocument: FSSpecPtr;
  251.                         VAR refNum: EditionRefNum): OSErr;
  252.     INLINE $303C,$0814,$A82D;
  253. FUNCTION CloseEdition(whichEdition: EditionRefNum;
  254.                       successful: BOOLEAN): OSErr;
  255.     INLINE $303C,$0316,$A82D;
  256. FUNCTION EditionHasFormat(whichEdition: EditionRefNum;
  257.                           whichFormat: FormatType;
  258.                           VAR formatSize: Size): OSErr;
  259.     INLINE $303C,$0618,$A82D;
  260. FUNCTION ReadEdition(whichEdition: EditionRefNum;
  261.                      whichFormat: FormatType;
  262.                      buffPtr: UNIV Ptr;
  263.                      VAR buffLen: Size): OSErr;
  264.     INLINE $303C,$081A,$A82D;
  265. FUNCTION WriteEdition(whichEdition: EditionRefNum;
  266.                       whichFormat: FormatType;
  267.                       buffPtr: UNIV Ptr;
  268.                       buffLen: Size): OSErr;
  269.     INLINE $303C,$081C,$A82D;
  270. FUNCTION GetEditionFormatMark(whichEdition: EditionRefNum;
  271.                               whichFormat: FormatType;
  272.                               VAR currentMark: LONGINT): OSErr;
  273.     INLINE $303C,$061E,$A82D;
  274. FUNCTION SetEditionFormatMark(whichEdition: EditionRefNum;
  275.                               whichFormat: FormatType;
  276.                               setMarkTo: LONGINT): OSErr;
  277.     INLINE $303C,$0620,$A82D;
  278. FUNCTION GetEditionInfo(sectionH: SectionHandle;
  279.                         VAR editionInfo: EditionInfoRecord): OSErr;
  280.     INLINE $303C,$0422,$A82D;
  281. FUNCTION GoToPublisherSection(container: EditionContainerSpec): OSErr;
  282.     INLINE $303C,$0224,$A82D;
  283. FUNCTION GetLastEditionContainerUsed(VAR container: EditionContainerSpec): OSErr;
  284.     INLINE $303C,$0226,$A82D;
  285. FUNCTION GetStandardFormats(container: EditionContainerSpec;
  286.                             VAR previewFormat: FormatType;
  287.                             preview: Handle;
  288.                             publisherAlias: Handle;
  289.                             formats: Handle): OSErr;
  290.     INLINE $303C,$0A28,$A82D;
  291. FUNCTION GetEditionOpenerProc(VAR opener: EditionOpenerProcPtr): OSErr;
  292.     INLINE $303C,$022A,$A82D;
  293. FUNCTION SetEditionOpenerProc(opener: EditionOpenerProcPtr): OSErr;
  294.     INLINE $303C,$022C,$A82D;
  295. FUNCTION CallEditionOpenerProc(selector: EditionOpenerVerb;
  296.                                VAR PB: EditionOpenerParamBlock;
  297.                                routine: EditionOpenerProcPtr): OSErr;
  298.     INLINE $303C,$052E,$A82D;
  299. FUNCTION CallFormatIOProc(selector: FormatIOVerb;
  300.                           VAR PB: FormatIOParamBlock;
  301.                           routine: FormatIOProcPtr): OSErr;
  302.     INLINE $303C,$0530,$A82D;
  303. FUNCTION NewSubscriberDialog(VAR reply: NewSubscriberReply): OSErr;
  304.     INLINE $303C,$0232,$A82D;
  305. FUNCTION NewSubscriberExpDialog(VAR reply: NewSubscriberReply;
  306.                                 where: Point;
  307.                                 expansionDITLresID: INTEGER;
  308.                                 dlgHook: ExpDlgHookProcPtr;
  309.                                 filterProc: ExpModalFilterProcPtr;
  310.                                 yourDataPtr:UNIV Ptr): OSErr;
  311.     INLINE $303C,$0B34,$A82D;
  312. FUNCTION NewPublisherDialog(VAR reply: NewPublisherReply): OSErr;
  313.     INLINE $303C,$0236,$A82D;
  314. FUNCTION NewPublisherExpDialog(VAR reply: NewPublisherReply;
  315.                                where: Point;
  316.                                expansionDITLresID: INTEGER;
  317.                                dlgHook: ExpDlgHookProcPtr;
  318.                                filterProc: ExpModalFilterProcPtr;
  319.                                yourDataPtr: UNIV Ptr): OSErr;
  320.     INLINE $303C,$0B38,$A82D;
  321. FUNCTION SectionOptionsDialog(VAR reply: SectionOptionsReply): OSErr;
  322.     INLINE $303C,$023A,$A82D;
  323. FUNCTION SectionOptionsExpDialog(VAR reply: SectionOptionsReply;
  324.                                  where: Point;
  325.                                  expansionDITLresID: INTEGER;
  326.                                  dlgHook: ExpDlgHookProcPtr;
  327.                                  filterProc: ExpModalFilterProcPtr;
  328.                                  yourDataPtr: UNIV Ptr): OSErr;
  329.     INLINE $303C,$0B3C,$A82D;
  330.  
  331.  
  332. {$ENDC}    { UsingEditions }
  333.  
  334. {$IFC NOT UsingIncludes}
  335.     END.
  336. {$ENDC}
  337.  
  338.